/*******************************************************************************
 * Copyright (c) 2012 March and Conquest.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package mrusanov.towers.main.ui.stats;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.tree.TreeModel;

import mrusanov.towers.localization.Localization;

import org.netbeans.swing.outline.DefaultOutlineModel;
import org.netbeans.swing.outline.Outline;
import org.netbeans.swing.outline.OutlineModel;

public class StatisticsFrame extends JFrame {
	private static final long serialVersionUID = -7865159250395165971L;

	private Outline outline;

	public StatisticsFrame() {
		setTitle(Localization.getString("ui.stats"));
		getContentPane().setLayout(new BorderLayout());
		outline = new Outline();
		outline.setRootVisible(false);
		getContentPane().add(new JScrollPane(outline), BorderLayout.CENTER);
		refreshModel();
		pack();
	}

	public final void refreshModel() {
		TreeModel treeMdl = new GameStatisticsTreeModelAdapter();
		OutlineModel mdl = DefaultOutlineModel.createOutlineModel(treeMdl, new GameStatisticsRowModel(), false,
				Localization.getString("ui.date"));
		outline.setModel(mdl);
		pack();
	}
}
